package com.zjx.springcloud.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.zjx.springcloud.entities.Dept;
import com.zjx.springcloud.service.DeptService;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.*;
import org.apache.shiro.subject.Subject;
import org.apache.solr.client.solrj.SolrClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;

/**
 * spring boot demo 接口
 */
@RestController
@RequestMapping("/home")
public class HomeIndexController {


    /**

     * @param
     * @return
     */
    @RequestMapping(value = "/login",method = {RequestMethod.POST,RequestMethod.GET})
    public JSONObject login(
          @RequestParam String username,
          @RequestParam String password
                                           ) {
        JSONObject res_jb = new JSONObject();

//       System.out.println("*********");
//
//            // 从SecurityUtils里边创建一个 subject
//          Subject subject=SecurityUtils.getSubject();
//       UsernamePasswordToken token = new UsernamePasswordToken(username, password);
//        try {
//            // 在认证提交前准备 token（令牌）
//
//            subject.login(token);
//        } catch (UnknownAccountException uae) {
//         //   return "未知账户";
//        } catch (IncorrectCredentialsException ice) {
//         //   return "密码不正确";
//        } catch (LockedAccountException lae) {
//         //   return "账户已锁定";
//        } catch (ExcessiveAttemptsException eae) {
//         //   return "用户名或密码错误次数过多";
//        } catch (AuthenticationException ae) {
//         //   return "用户名或密码不正确！";
//        }
//        if (subject.isAuthenticated()) {
//         //   return "登录成功";
//        } else {
//            token.clear();
//            res_jb.put("msg","登录失败");
//         //   return "登录失败";
//        }


            // 在认证提交前准备 token（令牌）



         return res_jb;

    }





}
